package tr.gov.tubitak.bilgem.esya.crlviewer;
import javax.swing.*;
import java.util.HashMap;

/**
 * Created by IntelliJ IDEA.
 * User: ramazan.girgin
 * Date: 20.10.2011
 * Time: 09:41
 * To change this template use File | Settings | File Templates.
 */
public class EImageManager
{
     private String imagedir = "/tr/gov/tubitak/bilgem/esya/crlviewer/images/";
    private  static  EImageManager mpInstance;
    public synchronized static  EImageManager getInstance()
    {
        if(mpInstance == null)
        {
            mpInstance = new EImageManager();
        }
        return  mpInstance;
    }

    public ImageIcon getImageIcon(String iImageName,String description)
    {
        return  getImageIconPath(imagedir+iImageName,description);
    }

    public ImageIcon getImageIconPath(String path,String description)
    {
        if(mImageIconMap.containsKey(path))
        {
            return mImageIconMap.get(path);
        }
        ImageIcon retImageIcon=null;
        try
        {
            retImageIcon =new ImageIcon(getClass().getResource(path));
        }
        catch (Exception e)
        {

        }
        //ImageIcon retImageIcon = new ImageIcon(path, description);
        mImageIconMap.put(path,retImageIcon);
        return retImageIcon;
    }

    private EImageManager()
    {
         mImageIconMap = new HashMap<String, ImageIcon>();
    }

    HashMap<String,ImageIcon> mImageIconMap;
}
